import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import type {RouteRecordRaw} from "vue-router"
const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'home',
    redirect: '/index',
    component: () => import('@/views/HomeView.vue'),
    children:[
      {
        path: '/index',
        name: 'index',
        component: () => import('@/views/index/index.vue'),
      },
      {
        path: '/green-power',
        name: 'green-power',
        meta: {
          title: '绿电供应'
        },
        component: () => import('@/views/green-power/index.vue'),
      },
      {
        path: '/shared-battery',
        name: 'shared-battery',
        meta: {
          title: '共享换电'
        },
        component: () => import('@/views/shared-battery/index.vue'),
      },
      {
        path: '/shared-capacity',
        name: 'shared-capacity',
        meta: {
          title: '共享运力'
        },
        component: () => import('@/views/shared-capacity/index.vue'),
      },
      {
        path: '/shared-travel',
        name: 'shared-travel',
        meta: {
          title: '共享出行'
        },
        component: () => import('@/views/shared-travel/index.vue'),
      },
      {
        path: '/nav-test',
        name: 'nav-test',
        component: () => import('@/views/nav-test.vue'),
      },
      {
        path: '/map-test',
        name: 'map-test',
        meta: {
          title: '地图测试'
        },
        component: () => import('@/components/gaode-map/test.vue'),
      }
    ]
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

router.beforeEach((to, from, next) => {
  next();
})

export default router
